{
  "id": 1811561422823611,
  "title": "{{device}}",
  "tags": ["{{pool}}"],
  "style": "dark",
  "timezone": "browser",
  "refresh": "15m",
  "editable": true,
  "hideControls": false,
  "sharedCrosshair": false,
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [ "5m","10m","15m"],
    "time_options": ["1h","3h","6h","12h","24h","2d","7d"]
  },
  "templating": {
    "list": [
    {% if extra_template != "dom" %}
      {% if port_types %}
        {% set comma = joiner(",") -%}
        {% for port_type in port_types -%}
          {% from 'template_port.j2' import ports -%}
          {{ comma() }}{{ ports(port_type, selected_types) }}
        {% endfor -%},
      {% endif %}

      {% if radio_types %}
        {% set comma = joiner(",") -%}
        {% for port_type in radio_types -%}
          {% from 'template_radio.j2' import radio -%}
          {{ comma() }}{{ radio(port_type) }}
        {% endfor -%},
      {% endif %}

      {% if subifaces %}
        {% from "template_subiface.j2" import subiface -%}
          {{ subiface(subifaces) }},
      {% endif %}
    {% endif %}
      {% include "template_device.j2" with context -%},
      {% include "template_vendor.j2" with context -%},
      {% include "template_platform.j2" with context -%},
      {% include "template_device_id.j2" with context -%},
      {% include "template_ip_info.j2" with context -%},
      {% include "template_segment.j2" with context -%},
      {% include "template_firmware_version.j2" with context -%},
      {% include "template_discovery_interval.j2" with context -%},
      {% include "template_bi_id.j2" with context -%},
      {% include "template_ping_interval.j2" with context -%}
    ]
  },

  "annotations": {
    "list": [
      {
        "datasource": "NocDS",
        "enable": false,
        "iconColor": "rgba(255, 96, 96, 1)",
        "name": "Alarm",
        "query": "{{device_id}}"
      }
    ]
  },
  "schemaVersion": 12,
  "version": 33,
  "links": [
    {
      "icon": "doc",
      "includeVars": true,
      "keepTime": true,
      "tags": [],
      "targetBlank": true,
      "type": "link",
      "title": "png",
      "tooltip": "png",
      "url": "/ui/grafana/render/dashboard/script/noc.js?width=1800&dashboard=mo&id={{device_id}}"
    },
    {
      "icon": "doc",
      "includeVars": true,
      "keepTime": true,
      "tags": [],
      "targetBlank": false,
      "type": "link",
      "title": {% if extra_template == "iface" %}"Standart View"{% else %}"PacketsView"{% endif %},
      "tooltip": {% if extra_template == "iface" %}"Interface by Load"{% else %}"Interface by Packets"{% endif %},
      "url": "/ui/grafana/dashboard/script/noc.js?width=1800&dashboard=mo{% if extra_template == "iface" %}{% else %}&extra_template=iface{% endif %}&id={{device_id}}"
    },
    {% if dom_types %}
        {
          "icon": "doc",
          "includeVars": true,
          "keepTime": true,
          "tags": [],
          "targetBlank": false,
          "type": "link",
          "title": {%if extra_template == "dom" %}"Standart View" {% else %}"DOM View"{% endif %},
          "tooltip": {%if extra_template == "dom" %}"Interface by Load"{% else %}"Interface DOM metrics"{% endif %},
          "url": "/ui/grafana/dashboard/script/noc.js?width=1800&dashboard=mo{% if extra_template == "dom" %}{% else %}&extra_template=dom{% endif %}&id={{device_id}}"
        },
    {% endif %}
    {
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "{{pool}}"
      ],
      "targetBlank": true,
      "type": "dashboards"
    },
    {
      "asDropdown": true,
      "icon": "external link",
      "includeVars": true,
      "tags": [
        "SYSTEM"
      ],
      "targetBlank": true,
      "type": "dashboards"
    }
  ],
  "gnetId": null,
  "rows": [
    {
      "collapse": false,
      "editable": false,
      "height": "250px",
      "showTitle": true,
      "internal_comment": "info_row",
      "title": "$device $ip $vendor $platform",
      "panels": [
      {% include "panel_device.j2" with context -%}
      {%if port_types %}
          ,
          {% include "panel_errors.j2" with context -%}
      {% endif %}
      ]

    }
    {% if extra_template == "dom" %}
        {% if dom_types %}
        ,
            {% set comma = joiner(",") -%}
            {% for dom in dom_types -%}
                {{ comma() }}

                {
                  "collapse": true,
                  "editable": false,
                  "height": "250px",
                  "showTitle": true,
                  "title": "DOM: {{dom.name}}",
                  "internal_comment": "dom_row",
                  "panels": [
                       {% if "optical_rx_dbm" in dom.metrics or "optical_tx_dbm" in dom.metrics %}
                          {% from "graph_dom_rxtxpower.j2" import interface -%}
                            {{interface(dom, loop.index)}},
                       {% endif %}
                       {% if "voltage_v" in dom.metrics or "current_ma" in dom.metrics %}
                          {% from "graph_dom_voltagebias.j2" import interface -%}
                            {{interface(dom, loop.index)}},
                       {% endif %}
                       {% if "temp_c" in dom.metrics %}
                          {% from "graph_dom_temperature.j2" import interface -%}
                            {{interface(dom, loop.index)}},
                       {% endif %}
                  ]
                }
            {%- endfor %}
        {% endif %}
    {% else %}
        {%if port_types %}
        ,
            {% set comma = joiner(",") -%}
            {% for port in port_types -%}
                {{ comma() }}
                {
                  "collapse": {% if port.type in selected_types and selected_types[port.type] %}false{% else %}true{% endif %},
                  "editable": false,
                  "height": "250px",
                  "showTitle": true,
                  "title": "{{port.name}}",
                  "internal_comment": "port_row",
                  "panels": [
                    {% if extra_template == "iface" %}
                        {% from "graph_interface_multi.j2" import interface -%}
                    {% else %}
                        {% from "graph_interface_load.j2" import interface -%}
                    {% endif %}
                    {{interface(port, loop.index)}}
                  ]
                }
            {%- endfor %}
        {% endif %}

        {%if subifaces %}
        ,
          {
            "collapse": true,
            "editable": false,
            "height": "250px",
            "showTitle": true,
            "title": "SubInterfaces",
            "internal_comment": "subif_row",
            "panels": [
              {% from "graph_subinterface_load.j2" import subinterface -%}
              {{subinterface()}}
            ]
          }
        {% endif %}
        {%if lags %}
        ,
            {% set comma = joiner(",") -%}
            {% for lag in lags -%}

                {{ comma() }}{
                  "collapse": true,
                  "editable": false,
                  "height": "250px",
                  "showTitle": true,
                  "title": "{{lag.name}} ({{lag.descr}})",
                  "internal_comment": "lags_row",
                  "panels": [
                    {% from "graph_interface_load_lag.j2" import interface -%}
                    {{interface(lag, loop.index)}}
                  ]
                }
            {%- endfor %}
        {% endif %}

        {% if port_types %}
        ,
            {% include "row_errors.j2" with context -%}
        {% endif %}

        {% if radio_types %}
        ,
            {% set comma = joiner(",") -%}
            {% for radio in radio_types -%}
                {{ comma() }}

                {
                  "collapse": true,
                  "editable": false,
                  "height": "250px",
                  "showTitle": true,
                  "title": "Radio: {{radio.name}}",
                  "internal_comment": "radio_row",
                  "panels": [
                    {% if "tx_power" in radio.ports[0].metrics or "rx_power" in radio.ports[0].metrics %}
                      {% from "graph_radio_rxtxpower.j2" import interface -%}
                      {{interface(radio, loop.index)}},
                    {% endif %}

                    {% if "rssi" in radio.ports[0].metrics or "cnri" in radio.ports[0].metrics %}
                      {% from "graph_radio_cinr_rssi.j2" import interface -%}
                      {{interface(radio, loop.index)}},
                    {% endif %}

                    {% if "signal_level" in radio.ports[0].metrics or "noise_level" in radio.ports[0].metrics %}
                      {% from "graph_radio_signal_noise_level.j2" import interface -%}
                      {{interface(radio, loop.index)}},
                    {% endif %}
                  ]
                }
            {%- endfor %}
        {% endif %}

        {%if object_check_metrics %}
          ,
          {
            "collapse": true,
            "editable": false,
            "height": "250px",
            "showTitle": true,
            "internal_comment": "object_check_metrics",
            "title": "Check metrics",
            "panels": [
                {% for metric in object_check_metrics -%}
                  {% if "result" in metric.metric %}
                    {% include "graph_check_result.j2" with context -%},
                  {% endif %}
                  {% if "rtt" in metric.metric %}
                    {% include "graph_check_ping.j2" with context -%},
                  {% endif %}
                {%- endfor %}
            ]

          }
        {% endif %}

        {% if object_metrics %}
            ,
            {
              "collapse": false,
              "editable": false,
              "height": "250px",
              "showTitle": true,
              "internal_comment": "object_metrics",
              "title": "Objects metrics",
              "panels": [
                {% set comma = joiner(",") -%}
                {% for graph in object_metrics -%}
                  {% set template = 'graph_' + graph | lower() |replace(" ","") | replace("|","_") + '.j2' %}
                  {{ comma() }}{% include [template, "graph_default.j2"] ignore missing with context %}
                {%- endfor %}
              ]

            }
        {% endif %}
    {% endif %}
  ]
}
